var verify = require('../../../../../../../utils/verify-token.js')
var app = getApp()
Page({

	/**
	 * 页面的初始数据
	 */
	data: {
		height: 60,
	},

	/**
	 * 生命周期函数--监听页面加载
	 */
	onLoad: function(options) {
		// console.log(options);
		var deviceId = options.deviceId;
		var deviceGoodsAisleId = options.deviceGoodsAisleId;
		this.setData({
			sh: app.globalData.screenHeight,
			sw: app.globalData.screenWidth,
			deviceId: deviceId,
			deviceGoodsAisleId: deviceGoodsAisleId,
			textArea: ''
		})
	},
	//合并货道
	mergedAisle() {
		let that = this;
		let deviceId = that.data.deviceId;
		let deviceGoodsAisleId = that.data.deviceGoodsAisleId;
		let textArea = that.data.textArea;
		wx.request({
			url: app.globalData.baseUrl + 'vending/device/' + deviceId + '/merged/' + deviceGoodsAisleId,
			header: {
				'AUTHORIZATION': app.globalData.token,
				'content-type': 'application/x-www-form-urlencoded'
			},
			data: {
				textArea: textArea
			},
			method: 'put',
			success(res) {
				if (res.data.code == 60006) {
					verify.clearAll()
				} else if (res.data.code == 200) {
					wx.showToast({
						title:'成功',
						icon:'success',
						duration:2000
					})
					setTimeout(wx.navigateBack({}),2500);
				} else {
					wx.showModal({
						title: '操作失败',
						content: res.data.message,
					})
				}
			}
		})
	},

	bindTextAreaBlur: function(e) {
		this.setData({
			textArea: e.detail.value
		})
	},
	/**
	 * 生命周期函数--监听页面初次渲染完成
	 */
	onReady: function() {

	},

	/**
	 * 生命周期函数--监听页面显示
	 */
	onShow: function() {

	},

	/**
	 * 生命周期函数--监听页面隐藏
	 */
	onHide: function() {

	},

	/**
	 * 生命周期函数--监听页面卸载
	 */
	onUnload: function() {

	},

	/**
	 * 页面相关事件处理函数--监听用户下拉动作
	 */
	onPullDownRefresh: function() {

	},

	/**
	 * 页面上拉触底事件的处理函数
	 */
	onReachBottom: function() {

	},

	/**
	 * 用户点击右上角分享
	 */
	onShareAppMessage: function() {

	}
})
